package com.huangwenshuo.futurestarschoolmanagement.controller;

import com.huangwenshuo.futurestarschoolmanagement.exception.CustomRuntimeException;
import com.huangwenshuo.futurestarschoolmanagement.pojo.enums.RequestStateEnum;
import com.huangwenshuo.futurestarschoolmanagement.pojo.vo.PermissionsVo;
import com.huangwenshuo.futurestarschoolmanagement.pojo.vo.Result;
import com.huangwenshuo.futurestarschoolmanagement.pojo.vo.RolesVo;
import com.huangwenshuo.futurestarschoolmanagement.service.PermissionsService;
import com.huangwenshuo.futurestarschoolmanagement.utils.ResUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/per")
public class PermissionController {

    @Autowired
    private PermissionsService permissionsService;

    @GetMapping("/getRoles")
    public Result getRoles(int rid) {
        PermissionsVo permissionsVo = null;
        try {
            permissionsVo = permissionsService.getPermissionByRid(rid);
        } catch (CustomRuntimeException e) {
            return ResUtils.result(RequestStateEnum.FAILED.value(), "获取失败, " + e.getMessage());
        }
        return ResUtils.result(RequestStateEnum.SUCCESS.value(),permissionsVo,"获取成功");
    }
}
